<template>
  <!-- 执纪问责 -->
  <div class="zjwzPage" id="zjwz_echarts"></div>
</template>

<script>
export default {
  props: ["ZjwzData"],
  data() {
    return {
      zjwzList: [],
      xData: [],
      yDatalian: [],
      yDataxian: [],
      yDatafirst: [],
    };
  },
  mounted() {},
  created() {},
  methods: {
    handleGetZjwz(ZjwzData) {
      console.log("this.ZjwzData:" + ZjwzData);
      this.zjwzList = ZjwzData;
      this.xData = this.zjwzList.map((item) => item.month);
      // res.data.month;
      this.yDatalian = this.zjwzList.map((item) => item.liAnCounts);

      this.yDataxian = this.zjwzList.map((item) => item.xianSuoCounts);
      // res.data.xianSuoCounts;
      this.yDatafirst = this.zjwzList.map((item) => item.firstCounts);
      // res.data.firstCounts;
      setTimeout(() => {
        // this.handleGetZjwz();
        this.drawChart();
      }, 1000);
    },
    drawChart() {
      var myChart = this.$echarts.init(document.getElementById("zjwz_echarts"));
      var option = {
        tooltip: {
          trigger: "axis",
        },
        legend: {
          top: 10,
          left: 40,
          data: ["立案数", "线索处置", "第一种形态"],
          textStyle: {
            // 图例文字的样式
            color: "#d0e0fe",
            fontSize: 13,
            padding: [0, 0],
          },
        },
        grid: {
          top: "30%",
          left: "5%",
          right: "6%",
          bottom: "12%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: this.xData,
          axisLabel: {
            interval: 0,
            margin: 30,
            textStyle: {
              color: "#d0e0fe",
            },
          },
          axisLine: {
            lineStyle: {
              color: "#152f60",
            },
          },
        },
        yAxis: {
          name: "单位(例)",
          type: "value",
          axisLabel: {
            show: true,
            margin: 10,
            formatter: "{value}",
          },
          axisLine: {
            lineStyle: {
              color: "#8da8d5",
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: "#143162",
              type: "dotted",
            },
          },
        },
        series: [
          {
            name: "立案数",
            type: "line",
            data: this.yDatalian,
            itemStyle: {
              color: "#0ef9de",
            },
            lineStyle: {
              color: "#0ef9de",
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  // 渐变颜色
                  {
                    offset: 0,
                    color: "rgba(14,249,222,0.2)",
                  },
                  {
                    offset: 1,
                    color: "rgba(14,249,222,0)",
                  },
                ],
                global: false,
              },
            },
          },
          {
            name: "线索处置",
            type: "line",
            data: this.yDataxian,
            itemStyle: {
              color: "#fbc829",
            },
            lineStyle: {
              color: "#fbc829",
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  // 渐变颜色
                  {
                    offset: 0,
                    color: "rgba(251,200,41,0.2)",
                  },
                  {
                    offset: 1,
                    color: "rgba(251,200,41,0)",
                  },
                ],
                global: false,
              },
            },
          },
          {
            name: "第一种形态",
            type: "line",
            data: this.yDatafirst,
            itemStyle: {
              color: "#17b2ff",
            },
            lineStyle: {
              color: "#17b2ff",
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  // 渐变颜色
                  {
                    offset: 0,
                    color: "rgba(22,182,253,0.2)",
                  },
                  {
                    offset: 1,
                    color: "rgba(22,182,253,0)",
                  },
                ],
                global: false,
              },
            },
          },
        ],
      };
      myChart.setOption(option);
      // 图表自适应
      myChart.setOption(option);
      window.addEventListener("resize", function () {
        myChart.resize();
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.zjwzPage {
  width: 100%;
  height: 100%;
  overflow: hidden;
  transition: 0.5s;
}
</style>
